.\" $Revision: 1.10 $
.TH WILDMAT 3
.SH NAME
wildmat \- perform shell-style wildcard matching
.SH SYNOPSIS
.nf
.B "int"
.B "wildmat(text, pattern)"
.B "    char		*text;"
.B "    char		*pattern;"
.fi
.SH DESCRIPTION
.I Wildmat
compares the
.I text
against the
.I pattern
and
returns non-zero if the pattern matches the text.
The pattern is interpreted according to rules similar to shell filename
wildcards, and not as a full regular expression such as those handled by the
.IR grep (1)
family of programs or the
.IR regex (3)
or
.IR regexp (3)
set of routines.
.PP
The pattern is interpreted as follows:
.TP
.BI \e x
Turns off the special meaning of
.I x
and matches it directly; this is used mostly before a question mark or
asterisk, and is not special inside square brackets.
.TP
.B ?
Matches any single character.
.TP
.B *
Matches any sequence of zero or more characters.
.TP
.BI [ x...y ]
Matches any single character specified by the set
.IR x...y .
A minus sign may be used to indicate a range of characters.
That is,
.I [0\-5abc]
is a shorthand for
.IR [012345abc] .
More than one range may appear inside a character set;
.I [0-9a-zA-Z._]
matches almost all of the legal characters for a host name.
The close bracket,
.IR ] ,
may be used if it is the first character in the set.
The minus sign,
.IR \- ,
may be used if it is either the first or last character in the set.
.TP
.BI [^ x...y ]
This matches any character
.I not
in the set
.IR x...y ,
which is interpreted as described above.
For example,
.I [^]\-]
matches any character other than a close bracket or minus sign.
.SH HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> in 1986, and posted to Usenet
several times since then, most notably in comp.sources.misc in
March, 1991.
.PP
Lars Mathiesen <thorinn@diku.dk> enhanced the multi-asterisk failure
mode in early 1991.
.PP
Rich and Lars increased the efficiency of star patterns and reposted it
to comp.sources.misc in April, 1991.
.PP
Robert Elz <kre@munnari.oz.au> added minus sign and close bracket handling
in June, 1991.
.PP
.de R$
This is revision \\$3, dated \\$4.
..
.R$ $Id: wildmat.3,v 1.10 1992/04/03 06:30:05 rsalz Exp $
.SH "SEE ALSO"
grep(1), regex(3), regexp(3).
